import React, { Component } from 'react'
import Taro from '@tarojs/taro'
import { connect } from 'react-redux'
import { View, Button, Text, Image } from '@tarojs/components'

import { add, minus, asyncAdd } from '../../actions/counter'

import './index.scss'

import '../../assets/style/common.scss'
import pic from '../../assets/images/1.png'


@connect(({ counter }) => ({
  counter
}), (dispatch) => ({
  add() {
    dispatch(add())
  },
  dec() {
    dispatch(minus())
  },
  asyncAdd() {
    dispatch(asyncAdd())
  }
}))
class Index extends Component {

  state = {
    msg: "helloworld"
  }

  componentWillReceiveProps(nextProps) {
    console.log(this.props, nextProps)
  }

  componentWillUnmount() { }

  componentDidShow() { }

  componentDidHide() { }

  goLog() {
    console.log('go log')
    Taro.reLaunch({ url: "/pages/log/log" })
  }

  render() {
    return (
      <View className='index'>
        <Text className="title">{this.state.msg}</Text>
        <View><Text>太原2001</Text></View>
        <Image src={pic}></Image>
        <Button onClick={() => this.goLog()} >跳转到日志页面</Button>
      </View>
    )
  }
}

export default Index

